### texreg method for polr objects
extract.krls.quartile <- function(model, include.r2 = TRUE,
                         include.nobs = TRUE, ...) {

  r2 <- model$R2
  
  ddpcr::quiet(model.summary <- summary(model))
  
  coef <- model.summary$qcoefficients[,2]
  low25 <- model.summary$qcoefficients[,1]
  high75 <- model.summary$qcoefficients[,3]
  
  names <- rownames(model.summary$qcoefficients)
  
  n <- dim(model[[1]])[1]

  gof <- numeric()
  gof.names <- character()
  gof.decimal <- logical()
  
  if (include.r2 == TRUE) {
    gof <- c(gof, r2)
    gof.names <- c(gof.names, "R2")
    gof.decimal <- c(gof.decimal, TRUE)
  }

  if (include.nobs == TRUE) {
    gof <- c(gof, n)
    gof.names <- c(gof.names, "Number of Observations")
    gof.decimal <- c(gof.decimal, FALSE)
  }
  
  tr <- createTexreg(
    coef.names = names,
    coef = coef,
    ci.low = low25,
    ci.up = high75,
    gof.names = gof.names,
    gof = gof,
    gof.decimal = gof.decimal
  )
  return(tr)
}
